package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;

/**
 * Controller class for the DVD collection
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * @revised version English (Ab)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class DVDCtr
{
    //declare instance variables to reference containers
    //passed as arguments from the main class
    private DvdContainer dc;
    private LoanContainer lc;
    private Dvd myDvd;
    
    
    /**
     * Constructor for objects of class DVDCtr
     * @param dc The reference to DvdContainer
     */
    public DVDCtr()//DVD container is to be passed as parameter from the main controller
    {
        dc = DvdContainer.getInstance();
        lc = LoanContainer.getInstance();
    }
    
    /**
     * Search for a dvd
     * @param id The id of the dvd.
     * @param title The title off the dvd.
     * @param kunstner The name of the .
     * @param udgivelsesdato The date of the dvd creation.
     * @return Dvd The dvd object
     */
    public Dvd searchDvd(long id, String title, String kunstner, String udgivelsesdato)
    {
       return dc.searchDvd(id, title, kunstner, udgivelsesdato);
    }
    
    /**
     * Create a new dvd in DvdContainer
     * @param id The id of the dvd
     * @param title The title off the dvd
     * @param kunstner The name of the artist
     * @param udgivelsesdato The date of the dvd creation.
     */
    public void createDvd(long id, String title, String kunstner, String udgivelsesdato)
    {       
       Dvd mydvd =  new Dvd(id, title, kunstner, udgivelsesdato);
       dc.addDvd(mydvd);
    }
    
    /**
     * Search the DvdContainer for a dvd
     * @param no The id of the dvd
     */
    public void findDVD(long no)
    {
       dc.listDvd(no); 
    }
    
    /**
     * Delete a dvd in the DvdContainer
     * @param id The id of the dvd
     */
    public void deleteDvd(long id)
    {
        dc.deleteDvd(id);
        
    }
    
    public void searchEksemplar(String serienr)
    {
        dc.searchEksemplar(serienr);
    }
    
    public void deleteEksemplar(String serienr)
    {
        dc.deleteEksemplar(serienr);
    }
    
    /**
     *  Create a copy of the specified dvd and add a eksemplar to the dvd
     *  @param id The id of the dvd
     *  @param serienr The serian number od the dvd copy
     *  @param anskafdato The price for the dvd
     *  @param anskafpris The date the dvd is bought
     *  @param dvd ª description for the dvd
     */
    public void createCopy(long id, String serienr, String anskafdato, String anskafpris, String dvd)
    {
        dc.createEksemplar(id, serienr, anskafdato, anskafpris, dvd);
 //       eksemplar eks = new eksemplar(serienr, anskafdato, anskafpris, dvd);
 //       lc.addEksemplar(eks);
        
        
    }
    
    /**
     * Prints a list of all dvds
     */
    
    public void listDvd()
    {
        dc.listDvd();
    }
    
    /**
     * Prints a list of all dvds
     * and Copies
     */
    
    public void listAll(long id)
    {
          //returns a list of all dvds and their associated copies
         dc.listAll(id);
    }
    
    public void listEksemplarFromId(long id)
    {
        dc.listEksemplarFromId(id);
    }
    
}
